package com.fsxgt.datagrid.component.controller;

import java.io.IOException;
import java.util.List;
import java.util.concurrent.ExecutionException;

import org.apache.ibatis.executor.ExecutorException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson2.JSONObject;
import com.fsxgt.datagrid.component.bo.CmpCaseBO;
import com.fsxgt.datagrid.component.service.impl.CmpCaseService;
import com.fsxgt.datagrid.core.exception.DataGridException;
import com.fsxgt.datagrid.core.utils.ReturnT;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;

@Slf4j
@Api(tags = "条件分支接口", value = "CaseController")
@RequestMapping(produces = "application/json; charset=UTF-8",path = "/case")
@RestController
public class CaseController extends BaseController {


	@Autowired
	private CmpCaseService cmpCaseService;
	


	
	@ApiOperation(hidden = true, value = "查找节点", notes = "")
	@RequestMapping(path = "/findNodes", method = RequestMethod.POST)
	public ReturnT findTableNames(@RequestBody JSONObject param) throws DataGridException, IOException, ExecutorException, NumberFormatException, ExecutionException {

		List list=cmpCaseService.findNodes(param.getString("flowInfoId"));
		
		return new ReturnT(list);

	}
	

	
	@ApiOperation(hidden = true, value = "保存", notes = "")
	@RequestMapping(path = "/saveCase", method = RequestMethod.POST)
	public ReturnT saveCase(@RequestBody CmpCaseBO bo) throws DataGridException, IOException, ExecutorException, NumberFormatException, ExecutionException {
		
		cmpCaseService.saveCmpCase(bo);
		
		
		return new ReturnT();

	}
	
	@ApiOperation(hidden = true, value = "获取组件", notes = "")
	@RequestMapping(path = "/getCase", method = RequestMethod.POST)
	public ReturnT getCase(@RequestBody CmpCaseBO cmpCaseBO) throws DataGridException, IOException, ExecutorException, NumberFormatException, ExecutionException {
		
		CmpCaseBO bo = cmpCaseService.getCase(cmpCaseBO);
		
		return new ReturnT(bo);

	}
	
	
	
	
	


	

}